import {defineStore} from 'pinia'

export const useUserStore = defineStore('user', {
    /** Data */
    state: () => ({
        token: '',
        name:''
    }),
    actions: {
        setToken(token) {
            this.token = token
        },
        setName(name) {
            this.name = name
        }
    },
    persist: {
        storage: localStorage, // 使用sessionStorage
        key: 'aj-user', // 自定义存储键名
        paths: ['token','name'] // 只持久化name和age
    }
})
